package com.alphaking.controller.admin;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.alphaking.service.mingweicai.BlogService;

@Controller
public class BlogListController {

	@Resource
	private BlogService blogService;
	
	
	@RequestMapping("/admin/toBlogListPage")
	public String toBlogListPage(Model model, String mapArr) throws NoSuchFieldException, SecurityException {

		blogService.findBlogs(model, mapArr);
		return "/admin/blogList";
	}

	@RequestMapping("/admin/deleteBlog")
	public String delete(String id, RedirectAttributes arr,String mapArr) throws NoSuchFieldException, SecurityException{

		blogService.deleteBlog(id);
		arr.addAttribute("mapArr", mapArr);
		return "redirect:/admin/toBlogListPage";
	}

}
